<link type="text/css" rel="stylesheet" href="/html/js/ui/datepicker/style/ui.all.css">
</style>
<script src="/html/js/ui/datepicker/ui.datepicker.js">
</script>
<div id="zones">
	<div class="show_title">
		<h2>广告位列表</h2>
	</div>
    <div id="search_area" class="right">
        <input class="input" name="search_txt" id="search_txt" style="width:200px"/><input class="input" type="button" name="search_btn" value="搜索" />
    </div>
    <div class="clear">
    </div>
    <div class="top_action">
        <select class="select" name="action">
            <option value="0">批量动作</option>
            <option value="/admin/admin_zone/delzones">删除</option>
        </select>
        <input class="input" type="button" name="do_btn" id="do_btn" value="应用">
        </input><!--<select class="select" id="filter">
        <option value="0">查看全部分类目录</option>
        <option value="/admin/admin_manage/getzones?style=type&type=ka">卡市</option>
        </select>
        <input type="button" class="input" name="filter_btn" id="filter_btn" value="过滤">
        </input>-->
        <div class="page right">
            <if $page_info.page.previous_url>
                <a class='text' href='[@htmlspecialchars($page_info.page.previous_url)]'>上一页</a>
            </if>
            <foreach name="page_info.page.pages" key="key" var="var">
                <if $var.page_num == $page_info.current_page>
                    <span title="第[@htmlspecialchars($var.page_num)]页">[@htmlspecialchars($var.page_num)]</span>
                    <else>
                    <a class="num" href="[@htmlspecialchars($var.page_link)]" title="第[@htmlspecialchars($var.page_num)]页">[@htmlspecialchars($var.page_num)]</a>
                </if>
            </foreach>
            <if $page_info.page.next_url>
                <a class='text' href='[@htmlspecialchars($page_info.page.next_url)]'>下一页</a>
            </if>
        </div>
    </div>
    <if $result.zones>
        <table width="100%" class="fixed table">
            <thead>
                <tr>
                    <th width="10%">
                        <input type="checkbox" name="check_all"/>
                    </th>
                    <th width="16%">
                        位置名称
                    </th>
                    <th width="16%">
                        所属站点
                    </th>
                    <th width="16%">
                        联系人
                    </th>
                    <th width="17%">
                        电话
                    </th>
                    <th width="17%">
                        邮件
                    </th>
                    <th width="17%">
                        &nbsp;
                    </th>
                </tr>
            </thead>
            <tfoot>
                <tr>
                    <th width="10%">
                        <input type="checkbox" name="check_all"/>
                    </th>
                    <th width="16%">
                        位置名称
                    </th>
                    <th width="16%">
                        所属站点
                    </th>
                    <th width="16%">
                        联系人
                    </th>
                    <th width="17%">
                        电话
                    </th>
                    <th width="17%">
                        邮件
                    </th>
                    <th width="17%">
                        &nbsp;
                    </th>
                </tr>
            </tfoot>
            <tbody>
                <foreach name="result.zones" var="zone" key="key">
                    <tr class="table_list">
                        <th>
                            <input type="checkbox" id="[$zone.z_id]" value="[$zone.z_id]"/>
                        </th>
                        <td>
                            [@htmlspecialchars($zone.z_name)]
                            <div class="row_action" num="[$zone.z_id]">
                                <span class="action_edit"><a href="/admin/admin_zone/editzone">编辑</a></span>
                                | <span class="action_delete"><a href="javascript:;">删除</a></span>
                                | <span class="action_adslist"><a href="http://ads.61.com/admin/admin_banner/getbannersbyzone?item=[$zone.z_id]">投放广告</a></span>
                            </div>
                        </td>
                        <td>
                            [@htmlspecialchars($zone.z_site)]
                        </td>
                        <td>
                            [@htmlspecialchars($zone.z_link_man)]
                        </td>
                        <td>
                            [@htmlspecialchars($zone.z_link_phone)]
                        </td>
                        <td>
                            [@htmlspecialchars($zone.z_link_email)]
                        </td>
                        <td>
                            <span><input class="get_code" type="button" key="[$zone.z_key]" value="获取代码"></span>
                        </td>
                    </tr>
                </foreach>
            </tbody>
        </table>
        <else>
        <div class="nothing">
            没有记录
        </div>
    </if>
    <div class="top_action">
        <div class="page right">
            <if $page_info.page.previous_url>
                <a class='text' href='[@htmlspecialchars($page_info.page.previous_url)]'>上一页</a>
            </if>
            <foreach name="page_info.page.pages" key="key" var="var">
                <if $var.page_num == $page_info.current_page>
                    <span title="第[@htmlspecialchars($var.page_num)]页">[@htmlspecialchars($var.page_num)]</span>
                    <else>
                    <a class="num" href="[@htmlspecialchars($var.page_link)]" title="第[@htmlspecialchars($var.page_num)]页">[@htmlspecialchars($var.page_num)]</a>
                </if>
            </foreach>
            <if $page_info.page.next_url>
                <a class='text' href='[@htmlspecialchars($page_info.page.next_url)]'>下一页</a>
            </if>
        </div>
    </div>
</div>
<script>
    $(function(){
        $.checkboxEvent();
        
        $("#do_btn").click(function(e){
            $.doBatchAction();
            return false;
        });
        
        /*$("#filter_btn").click(function(e){
         var filter = $("#filter").val();
         if (filter == "0") {
         $.showPageInfo("#page_info", '请过滤条件', 500, true);
         }
         else {
         $.getFilter(filter);
         }
         return false;
         });*/
        $.edit();
        $.delObject('/admin/admin_zone/delzones');
        $("[name=search_btn]").unbind('click').click(function(e){
            var $key = $("#search_txt").val();
            if ($key == "") {
                $.showPageInfo("#page_info", '请填写查询条件', 500, true);
                return false;
            }
            $url = "/admin/admin_zone/searchzones?keywords=" + $key;
            $.search($url);
            return false;
        });
        $("[name=ad_code]").click(function(){
            $(this).select();
        });
        $(".get_code").click(function(){
            var key = $(this).attr("key");
            var $url = "/admin/admin_zone/getscript";
			$("#code_area").empty();
            $("#code_div").dialog({
                closeOnEscape: true,
                closeBtn: '.dialog-modal-blackout',
                afterShow: function(){
                    $.ajax({
                        url: $url,
                        data: {
                            'key': key
                        },
                        success: function(data){
                            $("#code_area").fadeIn(150, function(){
								$(this).text(data);
                            });
                        }
                    });
                },
                showTime: 300,
                modal:true,
                center:true
            })
            return false;
        });
		$("#code_area").click(function(){
			$(this).select();
		});
        $.initForIe6();
    })
</script>
